package com.weiyi.mashangzhu.Roomer.Adapter;


import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.weiyi.mashangzhu.Base.BaseListAdapter;
import com.weiyi.mashangzhu.R;
import com.weiyi.mashangzhu.Roomer.Bean.FacilityInfo;

import java.util.List;

public class Facility_PopAdapter extends BaseAdapter {
    private Context context;
    private List<FacilityInfo> list;
    private  String type;

    public Facility_PopAdapter(Context context, List<FacilityInfo> list, String type) {
        this.context = context;
        this.list = list;
        this.type = type;
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.item_facility, null);
            holder = new ViewHolder();
            holder.facility = (TextView) convertView.findViewById(R.id.facility_tv);
            holder.imageView = (ImageView) convertView.findViewById(R.id.facility_img);
            convertView.setTag(holder);
        }
        holder = (ViewHolder) convertView.getTag();
        if (type.equals("yes")){
            holder.facility.setTextColor(context.getResources().getColor(R.color.colorPrimary));
            holder.imageView.setImageResource(list.get(position).getIcon_yes());
        }else {
            holder.facility.setTextColor(context.getResources().getColor(R.color.light_gray));
            holder.imageView.setImageResource(list.get(position).getIcon_no());
        }
        holder.facility.setText(list.get(position).getTitle());

//            Glide.with(context).load(list.get(position).getIcon()).error(R.mipmap.ic_launcher).into(holder.imageView);
        return convertView;
    }

    private class ViewHolder {
        private TextView facility;
        private ImageView imageView;
    }
}
